#include <iostream>
#include <string>
#include <math.h>
#include <set>
using namespace std;

static bool IsPrime(long long num) {
    const long long max = sqrt(num);
    for (long long i = 2; i <= max; ++i) {
        if (num % i == 0)
            return false;
    }
    return true;
}

int Letters_1_9(int num) {
    switch(num) {
    case 1: return 3; // one
    case 2: return 2; // two
    case 3: return 5; // three
    case 4: return 4; // four
    case 5: return 4; // five
    case 6: return 3; // six
    case 7: return 5; // seven
    case 8: return 5; // eight
    case 9: return 4; // nine
    default: return 0;
    }
}

int Letters_10_19(int num) {
    switch(num) {
    case 10: return 3; // ten
    case 11: return 6; // eleven
    case 12: return 6; // twelve
    case 13: return 8; // thirteen
    case 14: return 8; // fourteen
    case 15: return 7; // fifteen
    case 16: return 7; // sixteen
    case 17: return 9; // seventeen
    case 18: return 8; // eighteen
    case 19: return 8; // nineteen
    defalt: return 0;
    }
}

int Letters_20_99(int num) {
    const int d0 = num % 10;
    const int d1 = (num/10) % 10;

    int res = 0;
    switch(d1) {
    case 2: res += 6; break; // twenty
    case 3: res += 6; break; // thirty
    case 4: res += 6; break; // fourty
    case 5: res += 5; break; // fifty
    case 6: res += 5; break; // sixty
    case 7: res += 7; break; // seventy
    case 8: res += 6; break; // eighty
    case 9: res += 6; break; // ninety
    }

    res += Letters_1_9(d0);
    return res;
}

int Letters_100_999(int num) {
    const int d2 = (num/100) % 10;

    int res = Letters_1_9(d2) + 7; // hundred
    int tmp = num - d2 * 100;
    if (tmp) {
        res += 3;
        
        if (tmp < 10)
            res += Letters_1_9(tmp);
        else if (tmp < 20)
            res += Letters_10_19(tmp);
        else
            res += Letters_20_99(tmp);
    }

    return res;
}

int LettersInNum(int num) {
    if (num == 1000)
        return 11; // one thousand

    if (num < 10)
        return Letters_1_9(num);
    else if (num < 20)
        return Letters_10_19(num);
    else if (num < 100)
        return Letters_20_99(num);
    else
        return Letters_100_999(num);
}

int main() {
    long long res = 0;
    for (int i = 1; i <= 1000; ++i) {
        const int cnt = LettersInNum(i);
        res += cnt;
        cout << i << "\t" << cnt << endl;
    }

    cout << "Result: " << res << endl;

    return 0;
}
